<include file="Base/header" /> 	
<div class="page-container">
	<include file="Base/menu" /> 
	<div class="page-content">
		<div class="container-fluid">
			<div class="row-fluid">
					<div class="span12"> 
						<!-- BEGIN PAGE TITLE & BREADCRUMB-->
						<h3 class="page-title">
						</h3>
						<ul class="breadcrumb">
							<li>
								<i class="icon-home"></i>
								<a href="/index.php/Admin/">首页</a> 
								<i class="icon-angle-right"></i>
							</li>
							<li><a href="#">设备分类管理</a></li>
							<i class="icon-angle-right"></i>
							<li><a href="#">新增</a></li>
						</ul>
						<!-- END PAGE TITLE & BREADCRUMB-->
					</div>
			</div>
			<div class="row-fluid">
				<div class="span12"> 
					<div class="portlet box blue tabbable">
						<div class="portlet-title">
							<div class="caption">
								<i class="icon-reorder"></i>
									<span class="hidden-480">新增</span>
							</div>
						</div>
					<div class="portlet-body form">
						<form  method="post" class="form-horizontal" id="formid">
							<div class="control-group"></div>
							<div class="control-group">
                        		<label class="control-label">设备分类名称</label>
                                <div class="controls">
                                    <input name="cate_name" type="text" class="m-wrap large" value="">
                                </div>
                            </div>
                            <div class="control-group">
                        		<label class="control-label">分类</label>
                                <div class="controls">
                                    <select placeholder="" class="m-wrap large" name="status" id="status">
			                            <option value="0">请选择</option>
			                            <option value="1">填写</option>
			                        	<option value="2">选择</option>
                                    </select>
                                    <span class="help-inline">请选择分类(填写或选择)</span>
                                </div>
                            </div>
                            <div class="control-group">
                        		<label class="control-label">说明</label>
                                <div class="controls">
                                	<textarea name="explanation" class="m-wrap large"></textarea>
                                    <span class="help-inline">添加对设备情况的说明</span>
                                </div>
                                
                            </div>
                          
                            <div class="control-group">
                        		<label class="control-label">要捕获的动物种类</label>
                                <div class="controls">
                                    <foreach name="animal" item="v">
                                    	<label><input type="checkbox" name="pest_cate[]" value="{$v['id']}">{$v['name']}</label>
			                        </foreach>
                                </div>
                            </div>
                            <!-- <div class="portlet-title">
                            	<div class="caption">
                            		<span class="hidden-480">设备情况</span>
                            	</div>
                            </div>
							<div class="control-group">
                        		<label class="control-label">设备情况</label>
                                <div class="controls">
                                    <input name="status[]" type="text" class="m-wrap medium" value="">
                                </div>
                            </div>
                            <div id="stInsertId" class="form-actions">
								<div type="button" id="addStatus" class="btn blue">添加设备情况</div>
							</div>
							<div class="portlet-title">
                            	<div class="caption">
                            		<span class="hidden-480">捕获情况说明</span>
                            	</div>
                            </div>
                            <div class="control-group">
                        		<label class="control-label">捕获情况名称</label>
                                <div class="controls">
                                    <input name="catch[]" type="text" class="m-wrap medium" value="">
                                </div>
                            </div>
                            <div id="ctInsertId" class="form-actions">
								<div type="button" id="addCatch" class="btn blue">添加捕获情况</div>
							</div> -->
							<div class="form-actions">
								<div type="submit" id="submit" class="btn blue"><i class="icon-ok"></i>添加</div>
							</div>
						</form>
					</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- <div id="status" style="display: none;">
		<div class="control-group">
			<label class="control-label">设备情况</label>
	        <div class="controls">
	            <input name="status[]" type="text" class="m-wrap medium">
	        </div>
	    </div>
	</div>
	<div id="catch" style="display: none;">
		<div class="control-group">
    		<label class="control-label">捕获情况</label>
            <div class="controls">
                <input name="catch[]" type="text" class="m-wrap medium" value="">
            </div>
        </div>
	</div> -->
</div>
<include file="Base/footer" />
<script src="__PUBLIC__/plugins/layer/layer.min.js"></script>
<script type="text/javascript">
	/*$("#addStatus").click(function(){
		$("#stInsertId").before($("#status").html());
	});
	$("#addCatch").click(function(){
		$("#ctInsertId").before($("#catch").html());
	});*/
</script>
<script type="text/javascript">

$("#submit").click(function(){
	var status = $("#status").val();
	if (status == 0) {
		layer.alert("请选择分类");
		return false;
	}
	var data=$('#formid').serialize();
   	$.ajax({
   		type:'POST',
   		dataType: "json",
        url: "{:U('Admin/Device/cateAdd')}",
        data: data,
        success:  function(result){
        	if(result.status==1){
                layer.alert(result.info,function(){self.location="__MODULE__/Device/cate";});
            }else if(result.status==0){
                //失败
                layer.alert(result.info);
            }
        }
    });
});

</script>
